package com.heima.comment.controller;

import com.heima.comment.dto.CommentDto;
import com.heima.comment.dto.CommentLikeDto;
import com.heima.comment.dto.CommentSaveDto;
import com.heima.comment.service.ICommentService;
import com.heima.common.dto.ResponseResult;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mr_Su
 * @version v1.0
 * @date 2022/7/6 18:45
 * @desciption
 */
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    @PostMapping("/save")
    @ApiOperation(value = "saveComment",notes = "保存发表评论")
    @ApiModelProperty(name = "dto",dataType = "CommentSaveDto",required = true)
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto){
        return commentService.saveComment(dto);
    }

    /**
     * 加载评论列表
     * @param dto
     * @return
     */
    @PostMapping("/load")
    @ApiOperation(value = "load",notes = "加载评论列表")
    @ApiModelProperty(name = "dto",dataType = "CommentDto",required = true)
    public ResponseResult load(@RequestBody CommentDto dto) {
        return commentService.load(dto);
    }

    /**
     * 点赞某一条评论
     * @param dto
     * @return
     */
    @PostMapping("/like")
    @ApiOperation(value = "like",notes = "点赞某一条评论")
    @ApiModelProperty(name = "dto",dataType = "CommentLikeDto",required = true)
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return commentService.like(dto);
    }
}
